// app.js
// 全局挂载弹窗工具
import './utils/utils'
//全局挂载网络请求工具
import './utils/http'
App({
  onLaunch() {
    // 读取token
    this.getToken()
  },
  getToken() {
    wx.getStorage({
      key: 'token',
      success: ({ data }) => {
        // this 指向应用实例
        this.token = data
      },
      fail() {},
    })
  },
  globalData: {},
  setToken(token, refresh_token) {
    //拼凑合法的token
    token = 'Bearer ' + token
    refresh_token = 'Bearer ' + refresh_token
    //本地存储token
    wx.setStorageSync('token', token)
    wx.setStorageSync('refreshToken', refresh_token)
    //全局更新token
    this.token = token
    this.token = refresh_token
  },
})
